<?php
abstract class Admin_Form_Widget implements Admin_Form_IEmbeddable
{
  protected
    $form,
    $name,
    $value,
    $options,
    $html_options;
  
  //----------------------------------------------------------------------------
  
  public function configure() {}
  abstract public function __toString();
  
  //----------------------------------------------------------------------------
  
  public function __construct($name, $options = null, $html_options = null)
  {
    $this->name = $name;
    $this->html_options = _parse_attributes($html_options);
    $this->options = _parse_attributes($options);
    
    $this->configure();
  }
  
  //----------------------------------------------------------------------------
  
  public function setValue($v)
  {
    $this->value = $v;
  }
  
  public function getValue()
  {
    return $this->value;
  }
  
  //-------------------------------------------------------------- IEMBEDDABLE -
  
  public function setParent($v)
  {
    $this->form = $v;
  }
  
  public function getParent()
  {
    return $this->form;
  }
  
  public function unsetParent()
  {
    $this->form = null;
  }
  
  //----------------------------------------------------------------------------
  
  public function getName()
  {
    if ($this->form)
      return $this->form->getName()."[{$this->name}]";
    else
      return $this->name;
  }
}